#pragma once
//#include <atlbase.h>
//#include <comdef.h>
//#include <dshow.h>
//#pragma comment (lib, "strmiids.lib")
//#import "qedit.dll" named_guids

//#include <comdef.h>

#pragma warning(push)
#pragma warning(disable: 4192 4278)
#import "qedit.dll" named_guids
#pragma warning(pop)
#pragma comment(lib, "strmiids.lib")
#include <dshow.h>


namespace DexterLib
{
    class HRESULT_ex
    {
    public:
        HRESULT hr;
        HRESULT_ex() { hr = S_OK; }
        void operator = (HRESULT hr_) { hr = hr_; if (FAILED(hr)) throw _com_error(hr); }
        void operator += (HRESULT hr_) { hr = hr_; }
        bool operator () () { return SUCCEEDED(hr); }
        bool operator ! () { return FAILED(hr); }
    };

    class COM_initializer
    {
    public:
        COM_initializer()
        {
            HRESULT_ex hr;
            hr = CoInitialize(0);
        }
        ~COM_initializer()
        {
            CoUninitialize();
        }
    };

#define XPAM_COM_USE_LIB DexterLib::COM_initializer __com_initializer;

    _COM_SMARTPTR_TYPEDEF(ICreateDevEnum, __uuidof(ICreateDevEnum));
    _COM_SMARTPTR_TYPEDEF(IEnumMoniker, __uuidof(IEnumMoniker));
    _COM_SMARTPTR_TYPEDEF(IMoniker, __uuidof(IMoniker));
    _COM_SMARTPTR_TYPEDEF(IBaseFilter, __uuidof(IBaseFilter));
    _COM_SMARTPTR_TYPEDEF(IGraphBuilder, __uuidof(IGraphBuilder));
    _COM_SMARTPTR_TYPEDEF(IPin, __uuidof(IPin));
    _COM_SMARTPTR_TYPEDEF(IEnumPins, __uuidof(IEnumPins));
    _COM_SMARTPTR_TYPEDEF(IMediaControl, __uuidof(IMediaControl));
    _COM_SMARTPTR_TYPEDEF(IMediaEvent, __uuidof(IMediaEvent));
    _COM_SMARTPTR_TYPEDEF(IAMStreamConfig, __uuidof(IAMStreamConfig));

}